/*
 * @Author: HZK
 * @Date: 2020-10-19 18:59:22
 * @LastEditTime: 2020-10-22 21:01:00
 * @LastEditors: hanfengmi
 * @Description: 
 */

class Vue{
    constructor(options){
        this.$options = options || {}
        this.$data = options.data || {}
        this.$method = options.method || {}
        this.$el = typeof options.el === 'string' ? document.querySelector(options.el) : options.el
        this._proxyData(this.$data)

        new Observer(this.$data)

        new Compiler(this)
    }

    _proxyData(data){
        Object.keys(data).forEach(key => {
            Object.defineProperty(this, key, {
                enumerable:true,
                configurable:true,
                get(){
                    return data[key]
                },
                set(newValue){
                    if( newValue === data[key]){
                        return 
                    }
                    data[key] = newValue
                }
            })
        })
    }
}